part of base.widgets;

class Button extends StatelessWidget {
  const Button({
    Key? key,
    this.icon,
    required this.text,
    this.enabled = true,
    this.color,
    this.disabledColor,
    this.radius = 4,
    this.textStyle,
    this.disabledTextStyle,
    this.onTap,
    this.width,
    this.height,
    this.margin,
    this.borderWidth = 0,
    this.borderColor,
  }) : super(key: key);
  final Widget? icon;
  final Color? color;
  final Color? disabledColor;
  final double radius;
  final TextStyle? textStyle;
  final TextStyle? disabledTextStyle;
  final String text;
  final double? height;
  final double? width;
  final Function()? onTap;
  final EdgeInsetsGeometry? margin;
  final bool enabled;
  final double borderWidth;
  final Color? borderColor;

  @override
  Widget build(BuildContext context) {
    return Container(
      margin: margin,
      child: Material(
        type: MaterialType.transparency,
        child: Ink(
          height: height ?? 44.h,
          width: width,
          decoration: BoxDecoration(
            color: enabled ? color : disabledColor,
            borderRadius: BorderRadius.circular(radius),
            border: borderColor != null
                ? Border.all(width: borderWidth, color: borderColor!)
                : null,
          ),
          child: InkWell(
            onTap: enabled ? onTap : null,
            borderRadius: BorderRadius.circular(radius),
            child: Container(
              alignment: Alignment.center,
              child: Row(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: [
                    icon ?? Container(),
                    Text(text, style: enabled ? textStyle : disabledTextStyle)
                  ]),
            ),
          ),
        ),
      ),
    );
  }
}
